package com.situ.crm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.situ.crm.entity.Role;
import com.situ.crm.mapper.RoleMapper;
import com.situ.crm.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.situ.crm.vo.LayUISelectMVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Gao
 * @since 2021-11-03
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<LayUISelectMVO> selectAllRoles() {
        List<Role> roles = roleMapper.selectList(new QueryWrapper<>());
        List<LayUISelectMVO> list = new ArrayList<>();
        for (Role role : roles) {
            LayUISelectMVO layUISelectMVO = new LayUISelectMVO();
            layUISelectMVO.setId(role.getId());
            layUISelectMVO.setName(role.getName());
            layUISelectMVO.setStatus(1);
            list.add(layUISelectMVO);
        }

        return list;
    }
}
